<?php
$cate_id = 0;
$goods_id = 0;
if ($_REQUEST ['m'] == 'Goods' && $_REQUEST ['a'] == 'showcate') {
	$cate_id = intval ( $_REQUEST ['id'] ); //商品分类
}

if ($_REQUEST ['m'] == 'Goods' && $_REQUEST ['a'] == 'show') {
	$goods_id = isset ( $_REQUEST ['id'] ) ? intval ( $_REQUEST ['id'] ) : 0;
}

if ($_REQUEST ['m'] == 'Goods' && $_REQUEST ['a'] == 'showByUname') {
    $uname = $_REQUEST['uname'];
    if($uname!='')
    {
    	$uname = rawurldecode($uname);
		$sql ="select id from ".DB_PREFIX."goods where u_name='".$uname."'";
		$goods_id =intval($GLOBALS['db']->getOneCached($sql));    	
    }	
}


    
$preview = isset ( $_REQUEST ['preview'] ) ? ( bool ) $_REQUEST ['preview'] : false;
$data = array ();
$goods_list = getTodayGoodsList ( $goods_id, $cate_id );
if (intval ( a_fanweC ( "VIEW_GOODS_LIST" ) ) == 1 && count ( $goods_list ) > 1 && $goods_id == 0) {
	$GLOBALS ['tpl']->assign ( "goods_list", $goods_list );
	$cate_info = $db->getRowCached ( "select * from " . DB_PREFIX . "goods_cate where id='{$cate_id}'" );
	
	if($_REQUEST['m'] =="Index" && $_REQUEST['a'] =="index")
		$data = array();
	else
		$data = array ('navs' => array (array ('name' => $cate_info ['name_1'], 'url' => a_u ( "Goods/showcate", "id-" . $cate_id ) ) ), "keyword" => $cate_info ['seokeyword_1'], "content" => $cate_info ['seocontent_1'] );
	
		$tpl->assign ( "cate_info", $cate_info );
} else {
	$goods = getGoodsItem ( $goods_id, C_CITY_ID, $preview, $cate_id, false );
	if($goods_id ==0 && $goods){
		foreach($goods_list as $k=>$v)
		{
			if(intval($v['id']) == $goods['id'])
			{
				unset($goods_list[$k]);
			}
		}
	}
	$GLOBALS ['tpl']->assign ( "today_list", $goods_list );
	$GLOBALS ['tpl']->assign ( "goods", $goods );
	if($_REQUEST['m'] =="Index" && $_REQUEST['a'] =="index")
		$data = array();
	else
	{
		if($goods)
		{
			if(strtolower($_REQUEST ['m']) == 'goods' && $_REQUEST ['a'] == 'showcate')
			{
				$infos = $GLOBALS['db']->getRowCached("select `name_1`,`seokeyword_1`,`seocontent_1` from ".DB_PREFIX."goods_cate where id={$cate_id}");
				$data = array ('navs' => array (array ('name' => $goods ['name_1'], 'url' => '' ) ), "keyword" => $goods ['seokeyword_1'].$infos ['seokeyword_1'], "content" => $goods ['seocontent_1'].$infos ['seocontent_1'] );
			}
			else
			{
				if($goods['seo_title'])
					$data = array ('navs' => array (array ('name' => $goods ['seo_title'], 'url' => $goods ['url'] ) ), "keyword" => $goods ['seokeyword_1'], "content" => $goods ['seocontent_1'] );
				else
					$data = array ('navs' => array (array ('name' => $goods ['name_1'], 'url' => $goods ['url'] ) ), "keyword" => $goods ['seokeyword_1'], "content" => $goods ['seocontent_1'] );
			}
		}
		else
		{
			if(strtolower($_REQUEST ['m']) == 'goods' && $_REQUEST ['a'] == 'showcate')
			{
				$infos = $GLOBALS['db']->getRowCached("select `name_1`,`seokeyword_1`,`seocontent_1` from ".DB_PREFIX."goods_cate where id={$cate_id}");
				$data = array ('navs' => array (array ('name' => $infos ['name_1'], 'url' => '' ) ), "keyword" => $infos ['seokeyword_1'], "content" => $infos ['seocontent_1'] );
			}
			else
				$data = array();
		}
	}

}
assignSeo ( $data );
require ROOT_PATH.'app/source/func/vote_func.php';
//输出投票
$GLOBALS ['tpl']->assign ( "vote", getVote());
//输出主菜单
$GLOBALS ['tpl']->assign ( "main_navs", assignNav ( 2 ) );
//输出城市
$GLOBALS ['tpl']->assign ( "city_list", getGroupCityList () );
if(!$goods)
	$GLOBALS['tpl']->assign("city_list1",getGroupCityList(true));
//输出友情链接
if(strtolower($_REQUEST["m"]) == 'index' && strtolower($_REQUEST["a"]) == 'index')
	$GLOBALS['tpl']->assign("links",assignLink());
//输出帮助
$GLOBALS ['tpl']->assign ( "help_center", assignHelp () );
$GLOBALS ['tpl']->display ( 'Page/index.moban' );
?>